package org.my.back;

//import spring.transactional.EnableNextTransaction;

import com.easyaop.api.pointcut.MethodPointcut;
import com.easyaop.api.event.BeforeEvent;
import com.easyaop.api.event.listener.MethodListener;
import com.easyaop.core.AroundsImpl;
import com.easyaop.core.EventsImpl;

import org.my.MyApplication;
import org.my.MyService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;

// @SpringBootApplication
// (exclude = TransactionAutoConfiguration.class)
//@EnableNextTransaction("org.my")
// @EnableAutoConfiguration
// (exclude = TransactionAutoConfiguration.class)

public class MyApplication22 {
    public static void main(String[] args) throws Throwable {
        System.out.println(111222122);
        ConfigurableApplicationContext spring = SpringApplication.run(MyApplication.class, args);
        MyService bean2 = spring.getBean(MyService.class);
        System.out.println(bean2.getClass());
        System.exit(0);
if(true)return;
        MyService2 bean1 = spring.getBean(MyService2.class);
        bean1.doHello(",", "");
        bean1.doHello(",", "");

        AroundsImpl.getInstance().add(MethodPointcut.of(MyService.class.getDeclaredMethods()[0]), (target, args1, joinPoint, method1) -> {
            return method1.call();
        });


        EventsImpl.getInstance().addEventListener(DefaultTransactionAttribute.class.getMethod("rollbackOn",
                Throwable.class), new MethodListener() {
            @Override
            public void before(BeforeEvent event) {
                event.skipOriginMethod(true);
            }
        });

        System.out.println("Spring context started");
        MyService bean = spring.getBean(MyService.class);
//        bean.hello("1");


        spring.getBeanDefinitionNames();
    }
}
